//
//  CMTime+Extension.swift
//  ImGuider X
//
//  Created by 陆涛 on 2018/10/10.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

extension TimeInterval {
    
    var durationText:String {
        
        if self.isNaN || self.isInfinite {
            
            return "00:00"
        }
        
        let hours = Int(self.truncatingRemainder(dividingBy: 86400) / 3600)
        let minutes = Int(self.truncatingRemainder(dividingBy: 3600) / 60)
        let seconds = Int(self.truncatingRemainder(dividingBy: 60))
        
        if hours > 0 {
            
            return String(format: "%i:%02i:%02i", hours, minutes, seconds)
        } else {
            
            return String(format: "%02i:%02i", minutes, seconds)
        }
    }
}

